package com.libraryManage.controller;

import com.libraryManage.commons.utils.ResponseEntity;
import com.libraryManage.service.HomePageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@Api(tags={"首页接口"})
@RestController
@CrossOrigin
@RequestMapping("/manager/homepage")//这是前端请求的路径
public class HomePageController {

    @Autowired
    HomePageService homePageService;

    @ApiOperation("查找总用户数量")
    @ApiResponses({
            @ApiResponse(code=0, message="成功"),
            @ApiResponse(code=500, message="系统异常"),
            @ApiResponse(code=999, message="未登录"),
            @ApiResponse(code=1000, message="数据有效性检查不通过"),
            @ApiResponse(code=1001, message="业务规则检查不通过")
    })
    @RequestMapping(value = "/userCount" , method = RequestMethod.GET)
    ResponseEntity<Integer>  userCount(){
        return homePageService.userCount();
    }


    @ApiOperation("查找图书数量")
    @ApiResponses({
            @ApiResponse(code=0, message="成功"),
            @ApiResponse(code=500, message="系统异常"),
            @ApiResponse(code=999, message="未登录"),
            @ApiResponse(code=1000, message="数据有效性检查不通过"),
            @ApiResponse(code=1001, message="业务规则检查不通过")
    })
    @RequestMapping(value = "/bookCount" , method= RequestMethod.GET)
    ResponseEntity<Integer> bookCount(){
        return homePageService.bookCount();
    }
}
